package main

import (
	"time"
	"gopkg.in/mgo.v2/bson"
	"oxy_server/module/log"
	"oxy_server/model"
)

type (
	productiongroup struct {
		ID bson.ObjectId `json:"_id" bson:"_id"`
		ProductID 					string `json:"productid" bson:"productid"`
		StyleNumber 				string `json:"stylenumber" bson:"stylenumber"`
		Cost 						string `json:"cost" bson:"cost"`
		Color						string `json:"color" bson:"color"`
		ClothingSupplier 			string `json:"clothingsupplier" bson:"clothingsupplier"`
		OrderDate 				 time.Time `json:"orderdate" bson:"orderdate"`
		OrderSKU 					string `json:"ordersku" bson:"ordersku"`
		InboundDate 			 time.Time `json:"inbounddate" bson:"inbounddate"`
		ErpInfoImport 				string `json:"erpinfoimport" bson:"erpinfoimport"`
		WhetherImportErpInfo		string `json:"whetherimporterpinfo" bson:"whetherimporterpinfo"`
		DueDatePicSample 			string `json:"duedatepicsample" bson:"duedatepicsample"`
		UploadTestReport 			[]string `json:"uploadtestreport" bson:"uploadtestreport"`
		UploadPdfTestReport 		[]string `json:"uploadpdftestreport" bson:"uploadpdftestreport"`
		UploadWaterReport 			[]string `json:"uploadwaterreport" bson:"uploadwaterreport"`
		CertificatePrintTemplate 	string `json:"certificateprinttemplate" bson:"certificateprinttemplate"`
		CertificatePrint			string `json:"certificateprint" bson:"certificateprint"`
		WatermarkPrintTemplate 		string `json:"watermarkprinttemplate" bson:"watermarkprinttemplate"`
		WatermarkPrint 				string `json:"watermarkprint" bson:"watermarkprint"`
		InboundDifferences			string `json:"inbounddifferences" bson:"inbounddifferences"`
		WatermarkNumber 			string `json:"watermarknumber" bson:"watermarknumber"`
		WatermarkSupplier 			string `json:"watermarksupplier" bson:"watermarksupplier"`
		WatermarkSingleMoney		string `json:"watermarksinglemoney" bson:"watermarksinglemoney"`
		CertificateNumber			string `json:"certificatenumber" bson:"certificatenumber"`
		CertificateSupplier			string `json:"certificatesupplier" bson:"certificatesupplier"`
		CertificateSingleMoney		string `json:"certificatesinglemoney" bson:"certificatesinglemoney"`
		SizemarkNumber 				string `json:"sizemarknumber" bson:"sizemarknumber"`
		SizemarkSupplier 			string `json:"sizemarksupplier" bson:"sizemarksupplier"`
		SizemarkSingleMoney			string `json:"sizemarksinglemoney" bson:"sizemarksinglemoney"`
		Status						string `json:"status" bson:"status"`
		Fabricprice					string `json:"fabricprice" bson:"fabricprice"`
		Fabricsupplier				string `json:"fabricsupplier" bson:"fabricsupplier"`
		Featherprice				string `json:"featherprice" bson:"featherprice"`
		Feathersupplier				string `json:"feathersupplier" bson:"feathersupplier"`
		Factorymodelnumber			string `json:"factorymodelnumber" bson:"factorymodelnumber"`
		SaleCost					string `json:"salecost" bson:"salecost"`
		MaterialGroup				string `json:"materialgroup" bson:"materialgroup"`
	}
	designgroup struct {
		ID bson.ObjectId `json:"_id" bson:"_id"`
		ProductID 					string `json:"productid" bson:"productid"`
		ProductNumberStyleName		string `json:"productnumberstylename" bson:"productnumberstylename"`
		Color 						string `json:"color" bson:"color"`
		Material					string `json:"material" bson:"material"`
		Title						string `json:"title" bson:"title"`
		Content						string `json:"content" bson:"content"`
		UnitPrice					string `json:"unitprice" bson:"unitprice"`
		TotalPrice					string `json:"totalprice" bson:"totalprice"`
		ProcessTubePinCost			string `json:"processtubepincost" bson:"processtubepincost"`
		Cost 						string `json:"cost" bson:"cost"`
		ReferenceCard 				string `json:"referencecard" bson:"referencecard"`
		Features 					string `json:"features" bson:"features"`
		DesignAndTechnology 		string `json:"designandtechnology" bson:"designandtechnology"`
		ModelType		 			string `json:"modeltype" bson:"modeltype"`
		Note		 				string `json:"note" bson:"note"`
		Status						string `json:"status" bson:"status"`
		SaleCost					string `json:"salecost" bson:"salecost"`
		MaterialGroup				string `json:"materialgroup" bson:"materialgroup"`
		Clothversion				string `json:"clothversion" bson:"clothversion"`
	}
)


func main() {
	model.DB().Dbname="OxyCms"
	model.DB().Document="design_group"
	Dquery,_,err:=model.DB().Query(nil,0 ,0 )
	if err != nil {
		log.Error("查询出错",err)
	}
	alldesign:=[]designgroup{}
	Dquery.All(&alldesign)

	model.DB().Dbname="OxyCms"
	model.DB().Document="production_group"
	for _,designer := range alldesign {
		log.Info("designer.ProductID",designer.ProductID)
		err = model.DB().Update(bson.M{"productid":designer.ProductID} , 
			bson.M{"$set": bson.M{	"salecost": designer.SaleCost,
									"materialgroup":designer.MaterialGroup,
								},
				})
		if err != nil{
			log.Error("插入失败",err)
			return
		}
	}

	log.Info("success")
}